package com.kaifamiao.io.d0923;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

public class MethodDemo {

    public static void main(String[] args) {
        Class<Student> studentClass = Student.class;

        try {
            Method staticMethod = studentClass.getMethod("staticMethod");
            Constructor<Student> constructor = studentClass.getDeclaredConstructor(String.class);

            Student student = constructor.newInstance("zhangsan");

            staticMethod.invoke(null);

            System.out.println(student);

//            System.out.println(setName.getModifiers());
//            System.out.println(setName.getName());
//            System.out.println(setName.getParameterCount());
//            System.out.println(Arrays.toString(setName.getParameterTypes()));
//            System.out.println(setName.getDeclaringClass());
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
